<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 改属性，能触发界面更新 -->
        <button @click="obj.name = 'rose' ">修改name</button>
        <!-- 改指向，能触发界面更新 -->
        <button @click="obj = { name: 'andy', age: 19 } ">修改obj指向</button>
        <!-- 给对象动态添加属性,无法触发界面更新，也是vue2的缺陷 -->
        <button @click=" obj.sex = '男' ">加属性</button>
        <!-- 解决办法：用$set -->
        <button @click=" $set(obj, 'sex', '男') ">加属性-用$set</button>

        <ul>
            <li v-for="value in obj"> {{ value }}</li>
        </ul>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    obj: {
                        name: 'jack',
                        age: 16,
                        height: 175
                    }
                }
            },
        })
    </script>
</body>
</html>